<?php
 if (!isset($_SESSION['login']) or !isset($_SESSION['senha'])) {
    header('location:/index.html');
 }
if($_SESSION['permissao'] === '1'){
         header('location: index.php');
       }
    if(isset($_POST['senha'])){
        if ($_POST['senha'] === $_SESSION['senha']) {
            $cod = (int)$_POST['cod'];
            $matricula = (int)$_SESSION['matricula'];
            
            $sql2 = "SELECT * FROM requisicao WHERE dt_baixa IS NULL AND matricula_fun_baixa IS NULL AND cod_requisicao = $cod";
            $result2 = mysql_query($sql2)or die(mysql_error());
            $cont = mysql_num_rows($result2);
           
            if ($cont == 1) {
                $sql = "CALL fecha_requisicao($cod, $matricula)";
                $result = mysql_query($sql)or die(mysql_erro()); 
                 header("location:index.php?page=requisicao/listarequisicao.php&alert=Requisicao fechada.");
            }else{
                 header("location:index.php?page=requisicao/listarequisicao.php&alert=Erro, requisicao já fechada!");
            }
            
           
           
        
    }else{
        header("location:index.php?page=requisicao/listarequisicao.php&alert=Senha incorreta!");
    }
    }
?>
